import {Component, Input, OnInit} from '@angular/core';
import {ModalController} from "@ionic/angular";
import {UserInfo} from "../../../models/UserInfo";
import {StorageKey} from "../../Constants";
import {StorageService} from "../../services/storage.service";
import {HttpService} from "../../services/http/http.service";
import {API} from "../../services/API";

@Component({
  selector: 'app-process',
  templateUrl: './process.component.html',
  styleUrls: ['./process.component.scss'],
})
export class ProcessComponent implements OnInit {
  status = '0';
  pass = '1';
  @Input() serialno: string;
  businessLogs;
  constructor(
      private modalCtrl: ModalController,
      private storage: StorageService,
      private httpService: HttpService,
  ) {

  }

  async ngOnInit() {
    let userInfo: UserInfo = await this.storage.read(StorageKey.PERSON_INFO);
    userInfo = userInfo? userInfo: {};
    const param = {
      serialno: this.serialno,
      userId: userInfo.userId,
    }
    const info = await this.httpService.post(API.PROCESS_LIST, param, false);
    console.log(info);
    this.businessLogs = info.businessLogs;
  }

  onPageDidLeave() {
    this.modalCtrl.dismiss({
      'dismissed': true
    });
  }
  // 关闭流程图
  close() {
    this.modalCtrl.dismiss({
      'dismissed': true
    });
  }
}
